package com.xbongbong.saas.model.impl;

import com.xbongbong.paas.toolbox.util.DateUtil;
import com.xbongbong.saas.domain.dao.KnowledgeCatalogueDao;
import com.xbongbong.saas.domain.entity.KnowledgeCatalogueEntity;
import com.xbongbong.saas.model.KnowledgeCatalogueModel;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @Author mingliang
 * @Description 知识库目录Model
 * @Date 2022/6/21 15:14
 **/
@Service("knowledgeCatalogueModel")
public class KnowledgeCatalogueModelImpl implements KnowledgeCatalogueModel {
    @Resource
    private KnowledgeCatalogueDao knowledgeCatalogueDao;

    @Override
    public Integer insert(KnowledgeCatalogueEntity entity) {
        long now = DateUtil.getInt();
        entity.setAddTime(now);
        entity.setUpdateTime(now);
        return knowledgeCatalogueDao.insert(entity);
    }

    @Override
    public void insertBatch(List<KnowledgeCatalogueEntity> list) {
        knowledgeCatalogueDao.insertBatch(list);
    }

    @Override
    public List<KnowledgeCatalogueEntity> findEntitys(Map<String, Object> param) {
        return knowledgeCatalogueDao.findEntitys(param);
    }

    @Override
    public Integer getEntitysCount(Map<String, Object> param) {
        return knowledgeCatalogueDao.getEntitysCount(param);
    }

    @Override
    public Integer update(KnowledgeCatalogueEntity entity) {
        long now = DateUtil.getInt();
        entity.setUpdateTime(now);
        return knowledgeCatalogueDao.update(entity);
    }

    @Override
    public KnowledgeCatalogueEntity getByKey(Long key, String corpid) {
        return knowledgeCatalogueDao.getByKey(key, corpid);
    }

    @Override
    public List findEntitysWithoutSub(Map<String, Object> param) {
        return knowledgeCatalogueDao.findEntitys(param);
    }

    @Override
    public Integer updateBatchSort(String corpid, List<KnowledgeCatalogueEntity> knowledgeCatalogueEntityList) {
        return knowledgeCatalogueDao.updateBatchSort(corpid,knowledgeCatalogueEntityList);
    }

    @Override
    public void deleteBatchByIds(Map<String, Object> param) {
        knowledgeCatalogueDao.deleteBatchByIds(param);
    }
}
